%% @author author <author@example.com>
%% @copyright YYYY author.

%% @doc TEMPLATE.

-module(myapp).
-author('author <author@example.com>').
-export([start/0, stop/0]).

ensure_started(App) ->
    case application:start(App) of
        ok ->
            ok;
        {error, {already_started, App}} ->
            ok
    end.

%% @spec start() -> ok
%% @doc Start the myapp server.
start() ->
    myapp_deps:ensure(),
	io:format("INFO:init log4erl......~n"),
    init_log4erl(),
    io:format("INFO:init crypto server......~n"),
    ensure_started(crypto),
	io:format("INFO:init myapp application......~n"),
    application:start(myapp).

%% @spec stop() -> ok
%% @doc Stop the myapp server.
stop() ->
    Res = application:stop(myapp),
    application:stop(crypto),
    Res.
init_log4erl() ->   
	application:start(log4erl),
	log4erl:add_console_appender(cmd_logs, {info, "%j %T [%L] %l%n"}),
	log4erl:info("info1 msg").
